// Mechanicoder
// 2022/10/16
#pragma once

#include <QMainWindow>
#include <QAbstractListModel>
#include <QListWidget>

#include <AIS_InteractiveContext.hxx>

#include <vector>

class AIS_InteractiveObject;
class View;
class TopoDS_Wire;

namespace Ui
{
    class CtrlWidgetUi;
}

class ListModel;

class ViewWindow : public QMainWindow
{
    Q_OBJECT
public:
    ViewWindow(QWidget* parent = nullptr);
    ~ViewWindow();

private slots:
    void OnImport();
    void OnHideShape();
    void OnAnimationObject();
    void OnAnimationCamera();
    void OnAnimationBoth();

private:
    void InitCtrlWidget();

    void DrawShape(const TopoDS_Shape& shape, const QString& name) const;

    bool IsAllCurve3D(const TopoDS_Shape& shape) const;

    Handle(AIS_InteractiveObject) GetDisplayedObj() const;
    AIS_ListOfInteractive GetDisplayedObjs() const;

private:
    Handle(AIS_InteractiveContext) _context;

    View* _view;
    Ui::CtrlWidgetUi* _ctrlUi;

    std::vector<Handle(AIS_InteractiveObject)> _generated;
};

class ModelList : public QListWidget
{
    Q_OBJECT
public:
    ModelList(QWidget* parent = nullptr);
    virtual ~ModelList();

    void SetupContext(const Handle(AIS_InteractiveContext)& context);

    void RecordModel(const Handle(AIS_InteractiveObject)& ais, const QString& name);

    void Clear();

private:
    void OnItemClicked(QListWidgetItem* item);

private:
    Handle(AIS_InteractiveContext) _context;
};
